// pages/logistics/logistics.js
var httpUtil = require('../../utils/httpUtil.js');
var util = require('../../utils/util.js');

var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderNumber:"",
    name:"",
    order:{},
    logisticsList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    var orderNumber = options.orderNumber;
    httpUtil.getHttp("/order/get_logistics?orderNumber=" + orderNumber, {}, function (res) {
      var list=[];
      if (res.logisticsList != null && res.logisticsList.Traces != null && res.logisticsList.Traces.length != null){  
         for (var i = res.logisticsList.Traces.length-1; i > 0;i--){
          var model = res.logisticsList.Traces[i];
           list.push(model)
        }
        if(list.length==0){
          list.push({ "AcceptStation": "暂无物流信息", "AcceptTime": "" })
        }
      }else{
        list.push({ "AcceptStation": "暂无物流信息","AcceptTime":""})
      }
        that.setData({
          order: res.order,
          name:res.name,
          logisticsList: list
        })
    })
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})